/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.sioc.tag;

import com.jspx.scriptmark.core.TagNode;
import com.jspx.scriptmark.parse.XmlEngineImpl;
import com.jspx.scriptmark.XmlEngine;
import com.jspx.utils.StringUtil;
import com.jspx.sioc.Sioc;
import java.io.IOException;
import java.util.List;
import com.jspx.utils.XMLUtil;
import org.xml.sax.SAXException;

/**
 * Created by IntelliJ IDEA.
 * User:chenYuan (mail:39793751@qq.com)
 * Date: 2007-2-12
 * Time: 15:06:29
 * <sioc namespace="global"/>
 */
public class SiocElement extends TagNode {
    public final static String tagName = "sioc";
    public SiocElement() {

    }

    public String getNamespace() throws IOException, SAXException {
        String namespace = XMLUtil.deleteQuote(getAttribute("name"));
        if (StringUtil.isNULL(namespace)) {
            namespace = XMLUtil.deleteQuote(getAttribute("namespace"));
        }
        if (StringUtil.isNULL(namespace)) {
            namespace = Sioc.global;
        }
        return namespace;
    }

    public String getApplication() throws IOException, SAXException {
        return XMLUtil.deleteQuote(getAttribute("application"));
    }

    public String getExtends() throws IOException, SAXException {
        String extend = XMLUtil.deleteQuote(getAttribute("extends"));
        if (StringUtil.isNULL(extend)) {
            extend = Sioc.global;
        }
        return extend;
    }

    public List<TagNode> getBeanElements() throws Exception
    {
        XmlEngine xmlEngine = new XmlEngineImpl();
        xmlEngine.putTag(BeanElement.tagName, BeanElement.class.getName());
        return xmlEngine.getTagNodes(getBody());
    }

    public List<TagNode> getIncludeElements() throws Exception
    {
        XmlEngine xmlEngine = new XmlEngineImpl();
        xmlEngine.putTag(IncludeElement.tagName, IncludeElement.class.getName());
        return xmlEngine.getTagNodes(getBody());
    }
}